################################################################################
#
# recalbox-romfs-n64
#
################################################################################

# Package generated with :
# ./scripts/linux/empack.py --force --system n64 --extension '.n64 .N64 .z64 .Z64 .v64 .V64 .zip .ZIP .7z .7Z' --fullname 'Nintendo 64' --platform n64 --theme n64 1:mupen64plus:gliden64:BR2_PACKAGE_MUPEN64PLUS_GLIDEN64 2:mupen64plus:n64:BR2_PACKAGE_MUPEN64PLUS_GLES2N64 3:mupen64plus:rice:BR2_PACKAGE_MUPEN64PLUS_GLES2RICE 4:mupen64plus:glide64mk2:BR2_PACKAGE_MUPEN64PLUS_VIDEO_GLIDE64MK2 5:libretro:mupen64plus:BR2_PACKAGE_LIBRETRO_MUPEN64PLUS

# Name the 3 vars as the package requires
RECALBOX_ROMFS_N64_SOURCE = 
RECALBOX_ROMFS_N64_SITE = 
RECALBOX_ROMFS_N64_INSTALL_STAGING = NO
# Set the system name
SYSTEM_NAME_N64 = n64
SYSTEM_XML_N64 = $(@D)/$(SYSTEM_NAME_N64).xml
# System rom path
SOURCE_ROMDIR_N64 = $(RECALBOX_ROMFS_N64_PKGDIR)/roms

# CONFIGGEN_STD_CMD is defined in recalbox-romfs, so take good care that
# variables are global across buildroot


ifneq ($(BR2_PACKAGE_MUPEN64PLUS_GLIDEN64)$(BR2_PACKAGE_MUPEN64PLUS_GLES2N64)$(BR2_PACKAGE_MUPEN64PLUS_GLES2RICE)$(BR2_PACKAGE_MUPEN64PLUS_VIDEO_GLIDE64MK2)$(BR2_PACKAGE_LIBRETRO_MUPEN64PLUS),)
define CONFIGURE_MAIN_N64_START
	$(call RECALBOX_ROMFS_CALL_ADD_SYSTEM,$(SYSTEM_XML_N64),Nintendo 64,$(SYSTEM_NAME_N64),.n64 .N64 .z64 .Z64 .v64 .V64 .zip .ZIP .7z .7Z,n64,n64)
endef

ifneq ($(BR2_PACKAGE_MUPEN64PLUS_GLIDEN64)$(BR2_PACKAGE_MUPEN64PLUS_GLES2N64)$(BR2_PACKAGE_MUPEN64PLUS_GLES2RICE)$(BR2_PACKAGE_MUPEN64PLUS_VIDEO_GLIDE64MK2)$(BR2_PACKAGE_LIBRETRO_MUPEN64PLUS),)
define CONFIGURE_N64_LIBRETRO_START
	$(call RECALBOX_ROMFS_CALL_START_EMULATOR,$(SYSTEM_XML_N64),libretro)
endef
ifeq ($(BR2_PACKAGE_LIBRETRO_MUPEN64PLUS),y)
define CONFIGURE_N64_LIBRETRO_MUPEN64PLUS_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_N64),mupen64plus,5)
endef
endif

define CONFIGURE_N64_LIBRETRO_END
	$(call RECALBOX_ROMFS_CALL_END_EMULATOR,$(SYSTEM_XML_N64))
endef
endif

ifneq ($(BR2_PACKAGE_MUPEN64PLUS_GLIDEN64)$(BR2_PACKAGE_MUPEN64PLUS_GLES2N64)$(BR2_PACKAGE_MUPEN64PLUS_GLES2RICE)$(BR2_PACKAGE_MUPEN64PLUS_VIDEO_GLIDE64MK2)$(BR2_PACKAGE_LIBRETRO_MUPEN64PLUS),)
define CONFIGURE_N64_MUPEN64PLUS_START
	$(call RECALBOX_ROMFS_CALL_START_EMULATOR,$(SYSTEM_XML_N64),mupen64plus)
endef
ifeq ($(BR2_PACKAGE_MUPEN64PLUS_GLES2RICE),y)
define CONFIGURE_N64_MUPEN64PLUS_RICE_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_N64),rice,3)
endef
endif

ifeq ($(BR2_PACKAGE_MUPEN64PLUS_VIDEO_GLIDE64MK2),y)
define CONFIGURE_N64_MUPEN64PLUS_GLIDE64MK2_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_N64),glide64mk2,4)
endef
endif

ifeq ($(BR2_PACKAGE_MUPEN64PLUS_GLES2N64),y)
define CONFIGURE_N64_MUPEN64PLUS_N64_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_N64),n64,2)
endef
endif

ifeq ($(BR2_PACKAGE_MUPEN64PLUS_GLIDEN64),y)
define CONFIGURE_N64_MUPEN64PLUS_GLIDEN64_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_N64),gliden64,1)
endef
endif

define CONFIGURE_N64_MUPEN64PLUS_END
	$(call RECALBOX_ROMFS_CALL_END_EMULATOR,$(SYSTEM_XML_N64))
endef
endif



define CONFIGURE_MAIN_N64_END
	$(call RECALBOX_ROMFS_CALL_END_SYSTEM,$(SYSTEM_XML_N64),$(SOURCE_ROMDIR_N64),$(@D))
endef
endif

define RECALBOX_ROMFS_N64_CONFIGURE_CMDS
	$(CONFIGURE_MAIN_N64_START)
	$(CONFIGURE_N64_LIBRETRO_START)
	$(CONFIGURE_N64_LIBRETRO_MUPEN64PLUS_DEF)
	$(CONFIGURE_N64_LIBRETRO_END)
	$(CONFIGURE_N64_MUPEN64PLUS_START)
	$(CONFIGURE_N64_MUPEN64PLUS_RICE_DEF)
	$(CONFIGURE_N64_MUPEN64PLUS_GLIDE64MK2_DEF)
	$(CONFIGURE_N64_MUPEN64PLUS_N64_DEF)
	$(CONFIGURE_N64_MUPEN64PLUS_GLIDEN64_DEF)
	$(CONFIGURE_N64_MUPEN64PLUS_END)
	$(CONFIGURE_MAIN_N64_END)
endef

$(eval $(generic-package))
